package com.ytjj.qmyx.mall.utils.wx;

import java.util.HashMap;
import java.util.Map;

public class WXBizMsgCryptManager {

	public static final String sToken = "PuR4EqKDm3FsunGRYdCT2p0ONGwi";
	/**
	 * replace the sCorpID to your corp id
	 */
	public static final String sCorpID = "ww55e42199bb319c36";
	public static final String sEncodingAESKey = "AGmQ4VJdJ98Kq3uOiZ0LSdalNbS2cLx43mjcfXGNCWw";

	private static Map<String, WXBizJsonMsgCrypt> crypts = new HashMap<String, WXBizJsonMsgCrypt>();

	public static WXBizJsonMsgCrypt getChatWXBizMsgCrypt() {
		return getWXBizMsgCrypt(sToken, sEncodingAESKey, sCorpID);
	}

	public static WXBizJsonMsgCrypt getWXBizMsgCrypt(String token, String encodingAesKey, String corpId) {
		WXBizJsonMsgCrypt wxcpt = null;
		String key = corpId + "-" + token;
		if (crypts.containsKey(key)) {
			wxcpt = crypts.get(key);
		} else {
			try {
				wxcpt = new WXBizJsonMsgCrypt(token, encodingAesKey, corpId);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return wxcpt;
	}
}
